// run: $exec < test.in
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <cstring>

int const maxn = 100;
bool inqueue[maxn][maxn];
int dis[maxn][maxn][2];
int meet[maxn][maxn];
int n, m;

typedef std::pair<int, int> coord_type;

std::istream & operator>>(std::istream & is, coord_type & a)
{
	is >> a.first >> a.second;
	return is;
}

int const opt[8][2] = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1},
							{1, 0}, {1, -1}, {0, -1}, {-1, -1}};

bool inrange(coord_type const & a)
{
	return (0 <= a.first && a.first < n) && (0 <= a.second && a.second < m);
}

int calc_dis(coord_type const & a, coord_type const & b)
{
	return std::max(std::abs(a.first - b.first), std::abs(a.second - b.second));
}

int main()
{
	std::cin >> n >> m;
	coord_type a[2];
//	std::cin >> a[0] >> a[1];
	/*
	a[0].first = 5;
	a[0].second = 5;
	a[1].first = 17;
	a[1].second = 10;
	*/
	a[0].first = a[0].second = 0;
	a[1].first = n-1; a[1].second = m-1;


	for (int i = 0; i < 2; i++) {
		std::queue<coord_type> q;
		q.push(a[i]);
		std::memset(inqueue, 0, sizeof(inqueue));
		inqueue[a[i].first][a[i].second] = true;
		while (!q.empty()) {
			coord_type now = q.front(); q.pop();
			coord_type p;
			for (int ti = 0; ti < 8; ti++) {
				p.first = now.first + opt[ti][0];
				p.second = now.second + opt[ti][1];
				if (inrange(p) && !inqueue[p.first][p.second]) {
					dis[p.first][p.second][i] = dis[now.first][now.second][i] + 1;
					inqueue[p.first][p.second] = true;
					q.push(p);
				}
			}
		}
		std::cout << i << ":\n";
		for (int pi = 0; pi < n; pi++) {
			for (int pj = 0; pj < m; pj++) std::cout << std::setw(2) << dis[pi][pj][i] << ' ';
			std::cout << '\n';
		}
		std::cout << "----------\n";
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			//if (dis[i][j][0] == dis[i][j][1]) meet[i][j] = dis[i][j][0]; continue;
			coord_type p;
			for (int pi = 0; pi < 8; pi++) {
				p.first = i + opt[pi][0];
				p.second = j + opt[pi][1];
				if (inrange(p) && dis[p.first][p.second][1] == dis[i][j][0])
					meet[i][j] = meet[p.first][p.second] = 1;
			}
		}

	std::cout << '\n';
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			/*
			if (meet[i][j])
				std::cout << std::setw(2) << meet[i][j] << ' ';
			else
				std::cout << std::setw(2) << ' ' << ' ';
			*/
			if (meet[i][j]) std::cout << std::setw(2) << std::min(calc_dis({i, j}, a[0]), calc_dis({i, j}, a[1])) << ' ';
			else			std::cout << std::setw(2) << '-' << ' ';
		std::cout << '\n';
	}
}

